#ifndef __CACHE_H__
#define __CACHE_H__

#include "common.h"

#define CACHE_b 6
#define CACHE_L1_e 3
#define CACHE_L1_s 7
#define CACHE_L1_t 19

#define CACHE_B (1 << CACHE_b)
#define CACHE_L1_E (1 << CACHE_L1_e)
#define CACHE_L1_S (1 << CACHE_L1_s)

typedef struct {
    uint8_t data[CACHE_B];
    uint32_t  tag;
    bool val;
} cache_L1_block;//一个高速缓存块

typedef struct {
    cache_L1_block cache_L1_blocks[CACHE_L1_E];
} cache_L1_set;//一组E路组相连高速缓存块

cache_L1_set cache_L1[CACHE_L1_S];//整个L1高速缓存

void init_cache();
int read_cache_L1(hwaddr_t addr);
int write_cache_L1(hwaddr_t addr, size_t len, uint32_t data);

#endif
